<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>异常构造函数</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.exception.html">« Exception</a></li>
      <li style="float: right;"><a href="exception.getmessage.html">Exception::getMessage »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.exception.html">Exception</a></li>
    <li>异常构造函数</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="exception.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Exception::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">Exception::__construct</span> &mdash; <span class="dc-title">异常构造函数</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-exception.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Exception::__construct</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code><span class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$code</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type"><a href="class.throwable.html" class="type Throwable">Throwable</a></span><span class="type"></span></span> <code class="parameter">$previous</code><span class="initializer"> = <strong><code>null</code></strong></span></span>)</div>

  <p class="para rdfs-comment">
   异常构造函数。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-exception.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">message</code></dt>

     <dd>

      <p class="para">
       抛出的异常消息内容。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">code</code></dt>

     <dd>

      <p class="para">
       异常代码。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">previous</code></dt>

     <dd>

      <p class="para">
       异常链中的前一个异常。
      </p>
     </dd>

    
   </dl>

  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    如果子类的 $code 和 $message 属性已设置，在调用 Exception 父类的构造器时可以省略默认参数。
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 notes" id="refsect1-exception.construct-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    <code class="parameter">message</code> <em class="emphasis">不</em>是二进制安全的。
   </p>
  </p></blockquote>
 </div>


</div></div></div></body></html>